﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace show_time
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            push_button.Text = "时间显示按钮";
            push_button.Location = new Point(200, 200);
            push_button.Size = new Size(100, 40);
            box.Location = new Point(300, 300);
            box.Size = new Size(120, 80);
            //为  push_button 控件的 Click 事件添加了一个事件处理程序 push_button_test
            push_button.Click += new EventHandler(this.push_button_test);

            // 添加控件到窗体的 Controls 集合中
            this.Controls.Add(push_button);
            this.Controls.Add(box);
        }
        public void push_button_test(object sender, EventArgs e)
        {
            string str = DateTime.Now.ToString("yyy-MM-dd HH:mm:ss");
            this.box.Text = str;
         
        }
        //按钮和文本框 
        private Button push_button = new Button();
        private TextBox box = new TextBox();

    }
}
